#proevolytx@gmail.com
#2012/9/12
text = "1+2-3+4-5"

class postfix:
    def __init__(s, text):
        s.text = text
        s.index = 0
        if len(s.text):
            s.la = s.text[s.index]
        else:
            s.la = None
        s.out = ""
        
    def nextch(s):
        if s.index < len(s.text):
            s.index += 1
        if s.index < len(s.text):
            s.la = s.text[s.index]
        else:
            s.la = None
            
    def term(s):
        s.out += s.text[s.index]
        s.nextch()
            
    def expr(s):
        s.term()
        while True:
            if s.la == "+" or s.la == "-":
                tmp = s.la
                s.nextch()
                s.term()
                s.out += tmp
            else:
                break

test = postfix(text)
test.expr()
print test.out
